using System;
using System.Collections.Generic;
using System.Text;
using Barrage;
using SlimDX;
using Barrage.Render;
using Barrage.Global;
using Barrage.Items;
using Barrage.Scenes;
using Barrage.Textures;
using Barrage.Shaders;
using SlimDX.Direct3D9;
using Spacedash.Logic;
using Spacedash.Game.Scenes;
using Spacedash.Game.Subgames;
using NLog;

namespace Spacedash.Game
{
    enum GameState
    {
        MainMenu = 0,
        NewGameMenu = 1,
        Playing = 2,
        Configuration = 3,
        Profiles = 4,
        ModifyProfile = 5,
        EditProfile = 6,
        SelectProfile = 7,
        RaceResume = 8,
        Credits = 9,
        Finished = 100
    }
    class SpacedashGame : Barrage.Game
    {
        protected GameState state = GameState.MainMenu;

        public GameState State { get { return state; } }

        public SpacedashGame()
        {
        }

        public void FinishGame()
        {
            state = GameState.Finished;
        }

        public override void MainLoop()
        {
            base.MainLoop();
            if (state == GameState.Finished)
                finished = true;
        }

        public override void InitGame()
        {
            LoadSection(new MainMenuSection(this));            
        }

        protected override void LoadSection(GameSection section, bool initSection)
        {
            base.LoadSection(section, initSection);
            if (section != null)
                state = (GameState)section.Id;
        }

        public override GameSection GetSection(int sectionId)
        {
            switch ((GameState)sectionId)
            {
                case GameState.MainMenu:
                    return new MainMenuSection(this);
                case GameState.Configuration:
                    return new ConfigurationSection(this);
                case GameState.Profiles:
                    return new ProfilesSection(this);
                case GameState.ModifyProfile:
                    return new ModifyProfileSection(this);
                case GameState.NewGameMenu:
                    return new NewGameSection(this);
                case GameState.Credits:
                    return new CreditsSection(this);
            }
            return null;
        }
    }
}
